#ifndef HTTPPOSTRUNNABLE_H
#define HTTPPOSTRUNNABLE_H

#include <curl/curl.h>
#include <string>
#include <functional>
#include "Runnable.h"

class HttpPostRunnable: public sh::Runnable
{
public:
    typedef std::function<void(const std::string &response)> Response;

public:
    explicit HttpPostRunnable(CURL *curl);
    ~HttpPostRunnable() override;

    bool getResult() const;

    void setUrl(const std::string &url);
    void setData(const std::string &data);
    void setResponseCallback(const Response &response);

    static size_t response(char *ptr, size_t size, size_t nmemb, void *userdata);

private:
    void run() override;

private:
    CURL *curl;
    std::string url;
    std::string data;
    bool postResult;
    Response responseCallback;
};


#endif //HTTPPOSTRUNNABLE_H
